﻿@using Orchard.ContentManagement.Metadata.Models;

@{
    IEnumerable<dynamic> contentItems = Model.ContentItems;
    IEnumerable<ContentTypeDefinition> containedContentTypeDefinitions = Model.ContainedContentTypeDefinitions;
}

@if (!containedContentTypeDefinitions.Any())
{
    <p class="alert alert-warning">
        <a asp-action="EditTypePart" asp-controller="Admin" asp-route-area="Orchard.ContentTypes" asp-route-id="@Model.ContentItem.ContentType" asp-route-name="ListPart">@T["Please specify at least one contained content type."]</a>
    </p>
}
else
{
    <p>
        <div class="dropdown">
            <a class="btn btn-primary dropdown-toggle" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                @T["Create"]
            </a>

            <div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
                @foreach (var containedContentTypeDefinition in containedContentTypeDefinitions)
                {
                    <a class="dropdown-item" asp-action="Create" asp-controller="Admin" asp-route-id="@containedContentTypeDefinition.Name" asp-route-area="Orchard.Contents" asp-route-ListPart.ContainerId="@Model.ContentItem.ContentItemId">@containedContentTypeDefinition.DisplayName</a>
                }
            </div>
        </div>
    </p>
    @if (contentItems.Any())
    {
        <ul class="list-group">
            @foreach (var contentItemSummary in contentItems)
            {
                <li class="list-group-item">
                    @await DisplayAsync(contentItemSummary)
                </li>
            }
        </ul>

        @await DisplayAsync(Model.Pager)
    }
    else
    {
        <p class="alert alert-warning">@T["The list is empty."]</p>
    }
}